home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
005
/
curve10.arc
/
CURVE10.DOC
< prev
Wrap
Text File
|
1987-02-09
|
7KB
|
191 lines
C U R V E 1 0
-------------
CURVE10.COM is a public domain program written by :
L. R. Holliday
Vista Chemical Company
P. O. Box 500
Ponca City, Okla. 74602
(405) 767-6326
Copies of this program are not to be sold for profit. The program may be
copied freely. USERS assume all risks when using this program.
CURVE10.COM is an interactive linear curve-fitting program for the IBM PC,
originally written in TURBO PASCAL. It runs under DOS Version 2.0 or
higher. The program performs calculations similar to the Tektronix General
Graphing program, but no graphics capability is provided. If any
difficulty is experienced in using the program, please contact the above.
CURVE10 can handle up to 100 data points, and can read in values for up to
10 variables for each data point. It allows correlation of one Y with one X
using ten different equation forms. Any two of the variables can be chosen
for X and Y, and alternate variables can be chosen without exiting from the
program. Also, alternate data sets can be chosen without exiting from the
program.
The ten equation forms are listed below :
0. Y = b1 * X
1. Y = b0 + b1 * X
2. Y = b0 + b1 * ln(X)
3. Y = b0 + b1 / X
4. Y = exp(b0 + b1 * X)
5. Y = exp(b0 + b1 * ln(X)) = exp(b0) * X ^ b1
6. Y = exp(b0 + b1 / X)
7. Y = 1 / (b0 + b1 * X)
8. Y = 1 / (b0 + b1 * ln(X))
9. Y = 1 / (b0 + b1 / X)
The program calculates the b0 and b1 values for each of the above equations
by first linearizing the equations by transforming the variables.
Tranformations are as follows :
Equation X Transformation Y Transformation
-------- ---------------- ----------------
0 None None
1 None None
2 ln(X) None
3 1 / X None
4 None ln(Y)
5 ln(X) ln(Y)
6 1 / X ln(Y)
7 None 1 / Y
8 ln(X) 1 / Y
9 1 / X 1 / Y
The following equations are used to calculate the b0 and b1 values :
For Equation 0 :
b0 = 0.0
b1 = sum (X * Y) / sum (X * X)
For Equations 1 through 9 :
b1 = (n * sum (X * Y) - sum (X) * sum (Y)) /
(n * sum (X * X) - sum (X) * sum (X))
b0 = (sum (Y) - b1 * sum (X)) / n
R Square is calculated (after transforming the predicted values back to
their original form) by the formula :
R Square = 1.0 - (sum error squared) / (sum difference squared),
where sum error squared = the sum of squared differences between observed
values and predicted values, and sum difference squared = the sum of
squared differences between observed values and the average value.
Since this method is used for calculating R Square, negative values for R
Square can occur, if the equation is a very poor choice for fitting the
data. This is not likely to occur for equations 1,2, or 3, but could occur
for any of the other equations. This is because the values calculated for
b0 and b1 are the correct values for fitting the transformed Y values, but
are not neccessarily the correct values for fitting the original Y values.
Negative R Square values can be obtained for equation 0, even though Y was
not transformed, because the equation is forced through the origin.
Data Input
----------
Input to the program has been "bullet-proofed" to some extent. However, the
program can be made to abort by entering erroneous responses to some of the
prompts. A Ctrl-Break will sometimes cause a system halt.
The program can accept data directly from the keyboard or from (text) data
files. If data are entered from the keyboard, they will NOT be saved.
Also, errors made in entering a line of data from the keyboard cannot be
corrected after a carriage return has been issued.
A text data file can be created using any text editing program, such as
EDLIN or the Turbo Pascal compiler. A suitable data file can also be
created by using Lotus 1-2-3 to create a .PRN file. The data must be in
text form, with one line for each data point, and no line numbers. Each
value must be separated from the previous value by at least one blank
(several blanks are suggested to improve readability of the data file).
A sample data file, CURVE10.DAT, is provided to illustrate the data file
format.
Using the Program
-----------------
The program can be accessed by typing the file name (CURVE10).
The program then provides a series of prompts to the user :
INPUT FROM FILE (F) OR KEYBOARD (K)
?
ENTER NO. OF DATA POINTS AND NO. OF VARIABLES
? (Response to this prompt should be two integer values separated
by at least one blank)
If K was selected, the program prompts :
ENTER VALUES FOR VARIABLES n PER LINE
Point X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
----- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
1
(The user types in a value for each variable, up to the total
number of variables in the data set, followed by a carriage
return)
2
(etc.)
If F was selected, the program prompts :
ENTER FILENAME WHICH CONTAINS DATA (X:NAME.EXT)
?
After the file name has been entered and the data have been read correctly,
the program prompts :
ENTER VARIABLE NO. FOR X THEN Y
?
(If the user wants to correlate variable 2 with variable 5, the
correct response would be 2 5 <return> )
The program then will display a menu of choices :
ROUTINES AVAILABLE IN REGRESSIONS PACKAGE :
0. FIT DATA TO Y = B1 * X
1. FIT DATA TO Y = B0 + B1 * X
2. FIT DATA TO Y = B0 + B1 * ln(X)
3. FIT DATA TO Y = B0 + B1 * 1 / X
4. FIT DATA TO Y = exp(B0 + B1 * X)
5. FIT DATA TO Y = exp(B0) * (X ^ B1)
6. FIT DATA TO Y = exp(B0 * B1 / X)
7. FIT DATA TO Y = 1 / (B0 * B1 * X)
8. FIT DATA TO Y = 1 / (B0 * B1 * ln(X))
9. FIT DATA TO Y = 1 / (B0 * B1 * 1 / X)
10. FIT DATA TO ALL 10 EQUATIONS
11. CHOOSE NEW X AND Y
12. INPUT NEW DATASET
13. EXIT FROM PROGRAM
ENTER ROUTINE DESIRED (0 TO 13)
The user makes a selection from this menu, and the program responds
accordingly. At various points during execution, the program will ask the
user if he wants to send results to the printer and the screen
simultaneously. Also, the program will ask the user if he wants to see a
table of residuals (or see it and print it simultaneously). After
completing execution, the program will return to the menu above.
The user can go through the calculations once without printing the results,
and then repeat the calculations while printing the results. The program
will not actually repeat the calculations unless the user changes some
selection, but it will review the results just as if it were repeating the
calculations.
Please note that if an alphabetic character is input when a numeric value
is expected, the program will abort. This applies to all inputs except
responses to prompts from the menu above.
9 1 / X 1 / Y
Th